package com.smm.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

@Validated
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class User implements Serializable {
    private Integer id;
    @NotEmpty
    private String username;
    private String password;
    private String avatar;
    private String role;
    private Boolean status;
    @Email(message = "请输入合法的邮箱地址")
    private String email;
    private Set<Song> songs = new HashSet<Song>();

    @JsonIgnore
    public String getPassword() {
        return password;
    }
    @JsonProperty
    public User setPassword(String password) {
        this.password = password;
        return this;
    }


}
